import { useEffect, useState } from 'react'
import { getTag } from '../api/purchase'
import dayjs from 'dayjs'
interface Iprops{
  groupInfo:any
}
const stateType= ["0-待开始","1-预告中","2-进行中","3-已结束","4提前结束"]
function GroupBuyInfo (props:Iprops) {
  const groupInfo =  props.groupInfo
  const [tag,setTag] = useState({pic:''})
  useEffect(()=>{
      getTag({id:groupInfo.tag})
      .then(res=>{
        setTag(res.data.data[0])
      })
  },[])
  return ( <div className='GroupBuyInfo'>
    <h3>团购信息</h3>
    <dl>
      <dt>活动状态</dt>
      <dd>{stateType[groupInfo.state]}</dd>
      <dt>活动信息</dt>
      <dd>
        <p>活动名称:{groupInfo.name}</p>
        <p>活动时间：{dayjs(groupInfo.startTime).format("YYYY-MM-DD HH:mm:ss")}到{dayjs(groupInfo.endTime).format("YYYY-MM-DD HH:mm:ss")}</p>
        <p>广告语:{groupInfo.slogan}</p>
        <p>预告时间:{dayjs(groupInfo.previewTime).format("YYYY-MM-DD HH:mm:ss")}</p>
        <p>首页展示:{groupInfo.showHome?'是':'否'}</p>
        <p>促销标签：<img src={tag.pic}/></p>
        
      </dd>
       <dt>活动规则</dt>
        <dd>
        <p>顾客类型：{groupInfo.target===1?'不限':'新人'}</p>
        <p>是否限量：{groupInfo.limitBuy===999?'不限':groupInfo.limitBuy}</p>
        <p>提货方式:{groupInfo.deliverWay===1?'自提':'配送'}</p>




        </dd>
    </dl>

    {/* {JSON.stringify(props.groupInfo)} */}
    </div> );
}

export default GroupBuyInfo;